package net.chrisrichardson.ec2deployer.core;

 def class Metric {

   def sum = 0
   def count = 0
   def errors = 0

   def leftShift(timing) {
     sum += timing[0]
     if (timing[1] != 200)
       errors++
     count++
   }

   public String toString() {
     float avg = average()
     "[Metric: ${avg} ]"
   }
   def average() {
     (float)sum/count
   }

   def errorPercentage() {
     (float)errors/count * 100
   }
 }


